//
//  MidTableView.swift
//  知乎日报
//
//  Created by Ann on 2017/10/12.
//  Copyright © 2017年 Ann. All rights reserved.
//

import UIKit
let UserViewCellID = "UserViewCellID"
class MidTableView: UITableView,UITableViewDataSource {
    var plateList:Array<String>?{
        didSet{
        reloadData()
        }
    }
 
    override init(frame: CGRect, style: UITableViewStyle) {
    super.init(frame: frame, style: style)
        loadingPlist()
        backgroundColor = userViewBackground
        self.dataSource = self as? UITableViewDataSource
        self.register(PlateListCell.self, forCellReuseIdentifier: "UserViewCellID")
        self.separatorStyle = .none
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return plateList?.count ?? 0
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = dequeueReusableCell(withIdentifier: UserViewCellID, for: indexPath) as? PlateListCell
        cell?.object =  plateList?[indexPath.row]
      
        
        if cell == nil {
        return UITableViewCell()
        }
               
        return cell!
    }
    func loadingPlist(){
    
    let path = Bundle.main.path(forResource: "plate.plist", ofType: nil)
        
     plateList = NSArray.init(contentsOfFile: path!) as? Array<String>
         }
    
}
